﻿/**
 * ...
 * @author Sergey Mamyan
 */
package tx.facebook.methods;
import tx.json.JSON;
import neko.Lib;
import neko.Sys;
import tx.facebook.core.Request;

class IntegrationPointNames {
	public static var NOTIFICATIONS_PER_DAY					:String="notifications_per_day";
	public static var ANNOUNCEMENT_NOTIFICATIONS_PER_WEEK	:String="announcement_notifications_per_week";
	public static var REQUESTS_PER_DAY						:String="requests_per_day";
	public static var EMAILS_PER_DAY						:String="emails_per_day";
	public static var EMAIL_DISABLE_MESSAGE_LOCATION		:String="email_disable_message_location";
}
class ApplicationProperties {
	public static var APP_ID						:String = "app_id";
	public static var APPLICATION_NAME				:String = "application_name";
	public static var AUTHORIZE_URL					:String = "authorize_url";
	public static var BASE_DOMAIN					:String = "base_domain";
	public static var BASE_DOMAINS					:String = "base_domains";
	public static var CALLBACK_URL					:String = "callback_url";
	public static var CANVAS_NAME					:String = "canvas_name";
	public static var CONNECT_LOGO_URL				:String = "connect_logo_url";
	public static var CONNECT_PREVIEW_TEMPLATE		:String = "connect_preview_template";
	public static var CONNECT_RECLAIM_URL			:String = "connect_reclaim_url";
	public static var CONNECT_URL					:String = "connect_url";
	public static var CONTACT_EMAIL					:String = "contact_email";
	public static var CREATOR_UID					:String = "creator_uid";
	public static var DASHBOARD_URL					:String = "dashboard_url";
	public static var DESCRIPTION					:String = "description";
	public static var DESKTOP						:String = "desktop";
	public static var DEV_MODE						:String = "dev_mode";
	public static var EDIT_URL						:String = "edit_url";
	public static var EMAIL							:String = "email";
	public static var HELP_URL						:String = "help_url";
	public static var ICON_URL						:String = "icon_url";
	public static var IFRAME_ENABLE_UTIL			:String = "iframe_enable_util";
	public static var IGNORE_IP_WHITELIST_FOR_SS	:String = "ignore_ip_whitelist_for_ss";
	public static var INFO_CHANGED_URL				:String = "info_changed_url";
	public static var INSTALLABLE					:String = "installable";
	public static var IP_LIST						:String = "ip_list";
	public static var IS_MOBILE						:String = "is_mobile";
	public static var LOGO_URL						:String = "logo_url";
	public static var MESSAGE_ACTION				:String = "message_action";
	public static var POST_AUTHORIZE_REDIRECT_URL	:String = "post_authorize_redirect_url";
	public static var PRELOAD_FQL					:String = "preload_fql";
	public static var PRIVACY_URL					:String = "privacy_url";
	public static var PRIVATE_INSTALL				:String = "private_install";
	public static var PROFILE_TAB_URL				:String = "profile_tab_url";
	public static var PUBLISH_ACTION				:String = "publish_action";
	public static var PUBLISH_SELF_ACTION			:String = "publish_self_action";
	public static var PUBLISH_SELF_URL				:String = "publish_self_url";
	public static var PUBLISH_URL					:String = "publish_url";
	public static var QUICK_TRANSITIONS				:String = "quick_transitions";
	public static var SUPPORT_URL					:String = "support_url";
	public static var TAB_DEFAULT_NAME				:String = "tab_default_name";
	public static var TARGETED						:String = "targeted";
	public static var TOS_URL						:String = "tos_url";
	public static var UNINSTALL_URL					:String = "uninstall_url";
	public static var USE_IFRAME					:String = "use_iframe";
	public static var VIDEO_RENTALS					:String = "video_rentals";
	public static var WIDE_MODE						:String = "wide_mode";
	
	public static function all():Array < String > {
		var arr:Array<String> = Reflect.fields(ApplicationProperties);
		arr.remove("__name__");
		arr.remove("prototype");
		arr.remove("all");
		return arr.join(",").toLowerCase().split(",");
	}
}

class AdminMethods {
	
	public function new () {}
	
	public function getAllocation(integrationPointName:String, ?user:String):Int{
		var requst:Request = new Request("admin.getAllocation");
		requst.setParam("integration_point_name", integrationPointName);
		if (user != null){
			requst.setParam("user", user);
		}
		requst.call();
		return Std.parseInt(requst.response);
	}
	
	public function getAppProperties(properties:Array < String > ):Dynamic {
		var requst:Request = new Request("admin.getAppProperties");
		requst.setParam("properties", properties.join(","));
		requst.call();
		return JSON.decode(requst.response);
	}
}